import { MenuState } from "@/store/modules/auth"
import { success } from "../_utils"
import Mock from "mockjs"

const { Random } = Mock
const accessToken = Random.string("upper", 32, 32)
const refreshToken = Random.string("upper", 32, 32)

const userInfo = {
    username: "死牛胖子",
    avatar: "",
    gender: 1
}

const menus: MenuState[] = [
    {
        code: "dashboard",
        name: "仪表盘",
        path: "/dashboard",
        component: "Layout",
        show: true,
        icon: "DashboardOutlined",
        children: [
            {
                code: "dashboard:workbench",
                name: "工作台",
                show: true,
                path: "workbench",
                component: "/modules/dashboard/workbench/Index.vue",
                meta: { affix: true }
            }
        ]
    },
    {
        code: "system",
        name: "系统管理",
        path: "/system",
        component: "Layout",
        show: true,
        icon: "SettingOutlined",
        children: [
            {
                code: "system:user",
                name: "员工管理",
                show: true,
                path: "employee",
                component: "/modules/system/employee/Index.vue",
                meta: { keepAlive: true }
            },
            {
                code: "system:role",
                name: "角色管理",
                show: true,
                path: "role",
                component: "/modules/system/role/Index.vue",
                meta: { keepAlive: false }
            }
        ]
    }
]

export default [
    {
        url: "/api/login",
        timeout: 1000,
        method: "post",
        response: () => success({ accessToken, refreshToken, ...userInfo, permissions: ["*"], menus })
    },
    {
        url: "/api/logout",
        timeout: 1000,
        method: "post",
        response: () => success({})
    },
    {
        url: "/api/checkToken",
        timeout: 1000,
        method: "post",
        response: () => success({ accessToken, refreshToken, ...userInfo, permissions: ["*"], menus })
        //response: () => error("401")
    }
]
